package com.hzhr.iot.statis.dao;

import com.hzhr.iot.statis.dao.mapper.custom.GasUserMonthlyGasConsumeEntityCustomMapper;
import com.hzhr.iot.statis.dao.mapper.generator.GasUserMonthlyGasConsumeEntityMapper;
import com.hzhr.iot.statis.entity.GasUserMonthlyGasConsumeEntity;
import com.hzhr.iot.statis.entity.ext.GasUserMonthlyGasConsumeEntityExt;
import com.hzhr.iot.statis.queryModel.custom.GasUserMonthlyGasConsumeCustomQueryModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

@Repository
public class GasUserMonthlyGasConsumeDao {
    @Autowired
    GasUserMonthlyGasConsumeEntityMapper gasUserMonthlyGasConsumeEntityMapper;
    @Autowired
    GasUserMonthlyGasConsumeEntityCustomMapper gasUserMonthlyGasConsumeEntityCustomMapper;

    public int insert(GasUserMonthlyGasConsumeEntity record) {
        if (record == null) return 0;
        int changeCount = gasUserMonthlyGasConsumeEntityMapper.insert(record);
        return changeCount;
    }

    public int delete(GasUserMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = gasUserMonthlyGasConsumeEntityCustomMapper.delete(queryModel);
        return changeCount;
    }

    public int update(GasUserMonthlyGasConsumeEntity record) {
        if (record == null) return 0;
        int changeCount = gasUserMonthlyGasConsumeEntityMapper.updateByPrimaryKey(record);
        return changeCount;
    }

    public int updateProps(GasUserMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int changeCount = gasUserMonthlyGasConsumeEntityCustomMapper.updateProps(queryModel);
        return changeCount;
    }

    public GasUserMonthlyGasConsumeEntity selectEntity(GasUserMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<GasUserMonthlyGasConsumeEntityExt> extList = gasUserMonthlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<GasUserMonthlyGasConsumeEntity> selectEntityList(GasUserMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<GasUserMonthlyGasConsumeEntityExt> extList = gasUserMonthlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null) return null;
        List<GasUserMonthlyGasConsumeEntity> entityList = new ArrayList<>();
        for (GasUserMonthlyGasConsumeEntityExt ext : extList) {
            entityList.add(ext);
        }
        return entityList;
    }
    public GasUserMonthlyGasConsumeEntityExt selectExt(GasUserMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<GasUserMonthlyGasConsumeEntityExt> extList = gasUserMonthlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        if (extList == null || extList.size() == 0) return null;
        return extList.get(0);
    }
    public List<GasUserMonthlyGasConsumeEntityExt> selectExtList(GasUserMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return null;
        List<GasUserMonthlyGasConsumeEntityExt> extList = gasUserMonthlyGasConsumeEntityCustomMapper.selectExt(queryModel);
        return extList;
    }

    public int selectCount(GasUserMonthlyGasConsumeCustomQueryModel queryModel) {
        if (queryModel == null) return 0;
        int count = gasUserMonthlyGasConsumeEntityCustomMapper.selectCount(queryModel);
        return count;
    }
}
